﻿using System;
using System.Web;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.UI;

namespace ASPNETVN.PORTAL.Modules.FAQ.Controls
{
    public partial class AddItem : ModulePage
    {        
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
            }
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            // Create Item.            
            Components.Item Item = new Components.Item();
            Item.CategoryID = Convert.ToInt32(ddlCategory.SelectedValue);
            Item.Title = HttpUtility.HtmlEncode(txtTitle.Text);
            Item.isAnswer = isAnswer.NotAnwser;
            Item.Status = FAQStatus.NotApprove;
            Item.Name = txtNguoiGui.Text;
            Item.Email = txtEmail.Text;
            Item.QuesDate = DateTime.Now;
            Item.QuesContent = txtNoiDungHoi.Text;
            Item.Insert();
                        
            string url = HttpUrlBuilder.BuildModulePageUrl(this.ModuleID, 0, ModulePages.Item);
            Response.Redirect(url);
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            string url = HttpUrlBuilder.BuildModulePageUrl(this.ModuleID, 0, ModulePages.Item);
            Response.Redirect(url);
        }
    }
}